<template>
	<view >
		<view>
			<view>
				<zs v-for="item in list" :goditem='item' :key="item.objectId" :imagee='searchedList' :sou='rank'></zs>
			</view>
			<!-- <button @click="get()">获取</button> -->
		</view>
	</view>
</template>

<script>
	export default {


		data() {
			return {
				id: '',
				list: [],
				searchedList: [],
				rank:0
			}
		},
		async onLoad(option) {
			console.log(option)
			this.id = option
			this.data() // 输出 123
			// this.searchedList = this.lists
			this.image()
			this.hotsp()
			console.log(this.list)
		},
		

		methods: {
			hotsp(){
		
								  let url = `/1.1/classes/bscs`
								  this.$get(url).then(res => {
								  	uni.stopPullDownRefresh()
								  	// console.log(res)
								  	let {
								  		results
								  	} = res
								  	if (results.length) {
							
								  		this.hot_sp = res.results
								  		this.hot_sp.sort((a,b)=>b.sou-a.sou)
								  		// let index = this.hot_sp(this.goditem.xiangqing)
								  		// this.look = index+1
										let index=this.hot_sp.findIndex(item=> item.xiangqing===this.list[0].xiangqing)
										this.rank=index+1
								  		// console.log("在这里2",index)
								  	}
								  	// console.log(this.list)
								  	// console.log(this.hot_sp)
								  	// console.log("在这里",this.rank)
								  })
				
			},
			data() {
				console.log(this.id)

				let url = `/1.1/classes/bscs/` + this.id.id
				this.$get(url).then(res => {
					uni.stopPullDownRefresh()
					// console.log(res)
					let {
						results
					} = res
					this.list = this.list.concat(res)
					console.log(this.list)
				})
			},
			image(){
				let url = `/1.1/classes/image`
				
				let data={where:{image_id:this.id.id}}
				console.log(this.id.id)
				this.$get(url,data).then(res => {
					uni.stopPullDownRefresh()
					// console.log(res)
					let {
						results
					} = res
					this.searchedList = this.searchedList.concat(res.results)
					console.log(this.searchedList)
				})
			}

		}
	}
</script>

<style>

</style>